<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>ReportingObserver 使用</title>
    <style>
      .container {
        background-color: red;
        width: 300px;
        height: 300px;
        display: flex;
        justify-content: center;
        align-items: center;
        margin-bottom: 10px;
        /* transition: all .5s; */
      }
    </style>
  </head>
  <body>
    <h1>通过 ReportingObserver 监听来自浏览器的各种报告信息</h1>
    <div class="container" id="div">1</div>
  </body>
  <script>
    // 创建一个 ReportingObserver:
    const observer = new ReportingObserver(
      (reports, observer) => {
        for (const report of reports) {
          console.log(report.type, report.url, report.body)
        }
      },
      { types: ['deprecation'], buffered: true }
    )

    // 开始监听:
    observer.observe()
  </script>
</html>
